#include <stdio.h>
#define MATSIZE 4
int main()
{
    int a[MATSIZE][MATSIZE];
    int option;
    printf("请输入4×4二维数组");
    for(int i = 0;i<MATSIZE;i++)
    {
        for(int j = 0;j<MATSIZE;j++)
        {
            scanf("%d",&a[i][j]);
        }
    }
    printf("请输入要求的和，1为各行和，2为各列和");
    int b = 1;
    while(1)
    {
        scanf("%d",&option);
        switch (option)
        {
        case 1:
            for( int i = 0;i < MATSIZE; i++ )
            {
                for( int j = 0;j < MATSIZE - 1; j++ )
                    a[i][3] += a[i][j];
                printf("%d  ",a[i][3]);
            }
            break;
        case 2:
            for( int j = 0;j < MATSIZE; j++ )
            {
                for( int i = 0;i < MATSIZE - 1; i++ )
                    a[3][j] += a[i][j];
                printf("%4d  ",a[3][j]);
            }
            break;
        default:
            printf("不存在该选项，请重新输入");
            b = 0;
            break;
        }
        if(b) break;
    }

    return 0;
}